package com.youbug.system.schedule.jobs;

import com.youbug.system.config.annotation.MyJob;
import com.youbug.system.entity.Role;
import com.youbug.system.schedule.AbstractJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

@Slf4j
@MyJob("copySysDataToRemote")
public class CopySysDataToRemoteDB extends AbstractJob {

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public CopySysDataToRemoteDB(@Qualifier("remoteSysJdbcTemplate")JdbcTemplate jdbcTemplate){
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public void exec(){// 实际定时执行的代码

        List<Role> query = jdbcTemplate.query("select * from role", new BeanPropertyRowMapper<>(Role.class));
    }
}